package com.example.aigc_education.enums;

import lombok.Getter;

@Getter
public enum LanguageType {

    CHINESE("中文",0),
    ENGLISH("英语",1),
    JAPANESE("日语",2),
    KOREAN("韩语",3);

    private final String title;

    private final Integer value;

    LanguageType(String title, Integer value) {
        this.title = title;
        this.value = value;
    }

    public static LanguageType fromValue(Integer value) {
        for (LanguageType languageType : LanguageType.values()) {
            if (languageType.getValue().equals(value)) {
                return languageType;
            }
        }
        throw new IllegalArgumentException("No enum constant with value " + value);
    }

    public static LanguageType fromTitle(String title) {
        for (LanguageType languageType : LanguageType.values()) {
            if (languageType.getTitle().equals(title)) {
                return languageType;
            }
        }
        throw new IllegalArgumentException("No enum constant with value " + title);
    }
}
